package com.skin.admin.controller;

import com.skin.admin.entity.Result;
import com.skin.tools.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * json全局异常处理
 * Created by Administrator on 2018/8/2 0002.
 */
@ControllerAdvice
@ResponseBody
public class GlobalExceptionController {

    @ExceptionHandler(value = Exception.class)
    public Result<String> jsonErrorHandler(HttpServletRequest req, Exception e) throws Exception {
        return ResultUtil.error(e.getMessage());
    }
}
